import {
	post
} from './axios.js';
import store from '../store.js';


//获取地址列表
function getUserReceivingAddressList(p_data, callback) {
	let data = {
		"Token": store.getters.getToken,
		"PageIndex": p_data.PageIndex,
		"PageSize": 20
	};
	post('/user/getuserreceivingaddresslist', data, callback)
}

//添加或编辑地址
function saveUserReceivingAddress(p_data, callback) {
	let data = {
		"Token": store.getters.getToken,
		"Id": p_data.Id,                         //0新增，大于0编辑
		"UserId": store.getters.getUserInfo.Id,  //会员ID
		"ReceivingName": p_data.ReceivingName,   //收货人
		"MobileNo": p_data.MobileNo,             //手机号
		"Province": p_data.Province,             //省
		"City": p_data.City,                     //市
		"District": p_data.District,             //区
		"CAddress": p_data.CAddress,             //收货地址
		"IsDefault": p_data.IsDefault,           //是否默认地址
		"AddressType": p_data.AddressType,       //0 家， 1 公司， 2 学校 
	}
	post('/user/saveuserreceivingaddress', data, callback)
}

//添加或编辑地址
function delUserReceivingAddress(p_data, callback) {
	let data = {
		"Token": store.getters.getToken,
		"Id": p_data.id
	}
	post('/user/deluserreceivingaddress', data, callback)
}

export default {
	getUserReceivingAddressList: getUserReceivingAddressList,
	saveUserReceivingAddress: saveUserReceivingAddress,
	delUserReceivingAddress: delUserReceivingAddress
}
